Ext.define('AM.view.ProcedureJobView',{
	extend: 'Ext.form.Panel',
	alias : 'widget.procedureJobView',
    frame:true,
//	width : 700, 
	height: '80',
    autoHeight : true,
	layout : "form",
	labelWidth : 200,
	items: [{
						layout : "column",
						border : false,
						items: [{
					        	columnWidth :.48,
								layout : "form",
								border : false,
					   			items: [{
					   				    xtype : "textfield",
					   				    fieldLabel: '项目名称',
					   				    labelAlign :"right",
					   				    grow:true,
					   				    growMin:60,
					   				    growMax:300,
							            name: 'name'
							        }]		        	
				        		}
//				        			{ 
//					        	columnWidth :.20,
//					        	layout : "form",
//					        	border : false,
//							    items:[{
//							      	    xtype : "combobox",
//							      		labelAlign :"right",
//							            fieldLabel: '选择名称',
//							            name: 'step' 
//							        }]
//				        		}
				        		]
				        },{
					         layout : "column",
					         border : false,			 
						     items: [{
							        	columnWidth :.28,
										layout : "form",
										border : false,
							   			items: [{
							   				    xtype : "datefield",
							   				    labelAlign :"right",
							   				    fieldLabel: '开始时间',
									            name: 'startdate',
									            format:'Y-m-d',
									            width:30
									        }]		        	
				        
						        		},{
						        		   columnWidth :.28,
										   layout : "form",
										   border : false,
									   	   items: [{
									   				    xtype : "datefield",
									   				    labelAlign :"right",
									   				    fieldLabel: '计划完成时间',
											            name: 'planCompleteDate',
											            format:'Y-m-d',
											            width:30
									       			 }]		
							        		
								    }]
					    },{
							 layout : "column",
							 border : false,
							 items: [{
								       columnWidth :.28,
								       layout : "form",
								       border : false,
									   items:[{
													xtype : "combobox",
										      	    emptyText:'请选择部门',
										      	    selectOnFocus:true,
//										      	    id:'depart',
													forceSelection: true,
										      	    labelAlign :"right",
										            fieldLabel: '部门',
										            queryMode: 'local',
										            triggerAction:'all', 
										            name: 'dep',
										            store :"DepartmentStore",
										            displayField: 'name',
	    											valueField: 'name',
										            listeners:{   
																select:function(combo, record,index){
																	 try{
																		 var parent=Ext.getCmp('per');
																		 parent.clearValue();
																		 parent.store.load({params:{param:this.value}});
																	 }
																	 catch(ex){
																		 Ext.MessageBox.alert("错误","数据加载失败。");
																	 }
																}
															}
											 }]						        		           	
									},{
							        	columnWidth :.28,
							        	layout : "form",   
							            border : false,
									    items:[{
										        	 fieldLabel: '岗位—人员',
										        	 emptyText:'请选择人员',
										      	     xtype:"combobox",
										      	     labelAlign :"right",
										      	     selectOnFocus:true,
										      	     queryMode: 'local',
										      	     id:'per',
										      	     name: 'emp',
										      	     store :"EmployeesStore",
										             displayField: 'name',
	    											 valueField: 'name'
										 }]        	
							   	}]
						},{
						 	 layout : "column",
						 	 border : false,
							 items: [{
							 			 columnWidth :.45,
							 		     layout : "form",
									     border : false,
									     items: [{
							 			 xtype : "radiogroup",
							   			 labelAlign :"right",
							   		     fieldLabel: '工作周期',
							   			 columns: 3,
							   			 name: 'cycle',
        								 vertical: true,
										 items:[
											       { boxLabel: '一周', name: 'cycle', inputValue: '1',checked:true},
											       { boxLabel: '一月', name: 'cycle', inputValue: '2' },
												   { boxLabel: '一年', name: 'cycle', inputValue: '3' }										             
											]
									  }]		
								}]
						 },{
						 	 layout : "column",
					         border : false,			 
						     items: [{
							        	columnWidth :.75,
							        	layout : "form",
							        	border : false,
									    items:[{
									      	    xtype : "textarea",
									      	    labelAlign :"right",
									            fieldLabel: '工作要求',
									            name: 'jobRequirement',
									            height : 60
									        }]
						        	
						        },{
						        	columnWidth :.10,
									layout : "form",
									border : false,
									items: [{
									   		   xtype : "textfield",
									   		   labelAlign :"right",
									   		   fieldLabel: '状态',
											   name: 'state',
											   value: 1,
											   hidden:true            
							        	 }]
						        }]
						 }],
			  buttons : [
				 {text: '添加工作',
	  			 handler: function() {
				            var form = this.up('form').getForm();
				            if (form.isValid()) {
				                form.submit({
				                	url: 'jobDetail_addjob',
				                    success: function(form, action) {  
//				                     Ext.getCmp('performanceGridView').getStore().on('beforeload', function (store, options) {
//                                     	  var new_params = {searchValue:Ext.util.Format.date(searchValue, 'Y-m-d')}
//                                    	  Ext.apply(store.proxy.extraParams, new_params);
//                                  	  });
//				                    Ext.getCmp('performanceGridView').getStore().load();
				                   
				                    Ext.Msg.alert('添加','工作添加成功！！' );
				                    form.reset();
				                    },
				                    failure: function(form, action) {
				                   		 Ext.Msg.alert('查询失败','暂无此月信息' );
								   }
									   
							  });
				            }
				        }
	 			 },{
				     text: '重新设置',
				     handler : function() {
								this.up('form').getForm().reset();
							}
			}]
});